package com.xd.core.system.vo;

import io.swagger.annotations.ApiModel;
import lombok.Data;

@Data
@ApiModel
public class Resp<T> {
    private Integer code;
    private String msg = "操作成功";
    private T data;

    public Resp() {
    }

    public Resp(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Resp(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Resp success() {
        return success("操作成功");
    }

    public static Resp success(String msg) {
        return success(msg, (Object)null);
    }

    public static Resp success(String msg, Object data) {
        return new Resp(200, msg, data);
    }

    public static <T> Resp<T> success(T data) {
        return success("操作成功", data);
    }

    public static Resp error() {
        return error("操作失败");
    }

    public static Resp error(String msg) {
        return error(msg, (Object)null);
    }

    public static Resp error(String msg, Object data) {
        return new Resp(500, msg, data);
    }

    public static Resp error(int code, String msg) {
        return new Resp(code, msg, (Object)null);
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public T getData() {
        return this.data;
    }
}
